pull: Allow additional HTTP headers for summary fetch
authorDan Nicholson <nicholson@endlessm.com>
Mon, 8 May 2017 14:46:35 +0000 (09:46 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 8 May 2017 16:50:45 +0000 (16:50 +0000)
Read the http-headers (a(ss)) option in
ostree_repo_remote_fetch_summary_with_options like
ostree_repo_pull_with_options and add the headers to the fetcher. This
allows things like providing additional authorization headers to the
HTTP requests.

Closes: #839
Approved by: cgwalters

src/libostree/ostree-repo-pull.c

index 87f57e18fab83ff4da7cd3e0339c7d0f7b70d3db..7929b91a50853d2be305c81b1184c639a882a90f 100644 (file)
@@ -2460,10 +2460,14 @@ repo_remote_fetch_summary (OstreeRepo    *self,
   gboolean ret = FALSE;
   gboolean from_cache = FALSE;
   const char *url_override = NULL;
+  g_autoptr(GVariant) extra_headers = NULL;
   g_autoptr(GPtrArray) mirrorlist = NULL;
 
   if (options)
-    (void) g_variant_lookup (options, "override-url", "&s", &url_override);
+    {
+      (void) g_variant_lookup (options, "override-url", "&s", &url_override);
+      (void) g_variant_lookup (options, "http-headers", "@a(ss)", &extra_headers);
+    }
 
   mainctx = g_main_context_new ();
   g_main_context_push_thread_default (mainctx);
@@ -2472,6 +2476,9 @@ repo_remote_fetch_summary (OstreeRepo    *self,
   if (fetcher == NULL)
     goto out;
 
+  if (extra_headers)
+    _ostree_fetcher_set_extra_headers (fetcher, extra_headers);
+
   {
     g_autofree char *url_string = NULL;
     if (metalink_url_string)
@@ -3584,6 +3591,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
  * The following are currently defined:
  *
  * - override-url (s): Fetch summary from this URL if remote specifies no metalink in options
+ * - http-headers (a(ss)): Additional headers to add to all HTTP requests
  *
  * Returns: %TRUE on success, %FALSE on failure
  */